package com.itheima.bos.service.impl;

import com.itheima.bos.dao.IFunctionDao;
import com.itheima.bos.domain.Function;
import com.itheima.bos.domain.User;
import com.itheima.bos.service.IFunctionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by Mr.King on 2017/3/16.
 */
@Service
public class FunctionServiceImpl implements IFunctionService {

    @Autowired
    private IFunctionDao functionDao;

    @Override
    public List<Function> findAll() {
        return functionDao.findAll();
    }

    @Override
    public List<Function> findMenu(User loginUser) {
        List<Function> list = null;
        if (loginUser.getUsername().equals("admin")){
            //超级管理员，查询所有菜单数据
            list = functionDao.findAllMenu();
        }else {
            //普通用户，查询对应的权限菜单数据
            list = functionDao.findMenu(loginUser.getId());
        }
        return list;
    }
}
